home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- import sys
- import warnings
- from zope.interface import classProvides, implements, Interface
- from ZSI import EvaluateException, ParseException, ParsedSoap, SoapWriter
-
- def CheckInputArgs(*interfaces):
- l = len(interfaces)
-
- def wrapper(func):
-
- def check_args(self, *args, **kw):
- for i in range(len(args)):
- if l > i or interfaces[i].providedBy(args[i]) or interfaces[-1].providedBy(args[i]):
- continue
-
- if l > i:
- raise TypeError, 'arg %s does not implement %s' % (args[i], interfaces[i])
-
- raise TypeError, 'arg %s does not implement %s' % (args[i], interfaces[-1])
-
- func(self, *args, **kw)
-
- return check_args
-
- return wrapper
-
-
- class HandlerChainInterface(Interface):
-
- def processRequest(self, input, **kw):
- pass
-
-
- def processResponse(self, output, **kw):
- pass
-
-
-
- class CallbackChainInterface(Interface):
-
- def processRequest(self, input, **kw):
- pass
-
-
-
- class DataHandler:
- classProvides(HandlerChainInterface)
- readerClass = None
- writerClass = None
-
- def processRequest(cls, input, **kw):
- return ParsedSoap(input, readerclass = cls.readerClass)
-
- processRequest = classmethod(processRequest)
-
- def processResponse(cls, output, **kw):
- sw = SoapWriter(outputclass = cls.writerClass)
- sw.serialize(output)
- return sw
-
- processResponse = classmethod(processResponse)
-
-
- class DefaultHandlerChain:
-
- def __init__(self, cb, *handlers):
- self.handlercb = cb
- self.handlers = handlers
-
- __init__ = CheckInputArgs(CallbackChainInterface, HandlerChainInterface)(__init__)
-
- def processRequest(self, arg, **kw):
- for h in self.handlers:
- arg = h.processRequest(arg, **kw)
-
- return self.handlercb.processRequest(arg, **kw)
-
-
- def processResponse(self, arg, **kw):
- if arg is None:
- return None
-
- for h in self.handlers:
- arg = h.processResponse(arg, **kw)
-
- s = str(arg)
- return s
-
-
-